<template>
  <section class="market-section">
    <div class="market-container">
      <h2 class="section-title">版权市场</h2>
      <p class="section-subtitle">精选优质版权作品，打造创意交易新生态</p>
      
      <div class="works-grid">
        <div class="work-card" v-for="(work, index) in featuredWorks" :key="index" @click="viewWorkDetails(work)">
          <div class="work-image">
            <img :src="work.coverUrl" :alt="work.title">
            <div class="work-tags">
              <span :class="'tag-' + work.tradeType">{{ work.tradeTypeText }}</span>
            </div>
          </div>
          <div class="work-info">
            <h3 class="work-title">{{ work.title }}</h3>
            <p class="work-desc">{{ work.description }}</p>
            <div class="work-meta">
              <div class="work-price">
                <span class="price-label">价格</span>
                <span class="price-value">{{ work.priceDisplay }}</span>
              </div>
              <el-button class="work-btn" size="small">查看详情</el-button>
            </div>
          </div>
        </div>
      </div>
      
      <div class="view-more">
        <el-button 
          type="primary" 
          class="market-btn"
          @click="goToMarket"
        >
          浏览全部作品
        </el-button>
      </div>
    </div>
  </section>
</template>

<script>
import { defineComponent, ref } from 'vue'
import { useRouter } from 'vue-router'

export default defineComponent({
  name: 'CopyrightRegistration',

  setup() {
    const router = useRouter()
    
    // 示例作品数据
    const featuredWorks = ref([
      {
        id: '1',
        title: '艺术文化系列插画',
        description: '以中国传统文化为灵感创作的插画作品集，包含24幅精美插画，适用于出版、文创产品等领域。',
        coverUrl: new URL('@/assets/homeimg/work1.jpg', import.meta.url).href,
        priceDisplay: '¥3,200',
        tradeType: 'license',
        tradeTypeText: '授权使用'
      },
      {
        id: '2',
        title: '企业品牌音乐标识',
        description: '原创音乐作品，为企业品牌量身定制，包含品牌主题曲、短版本及音效包，可用于广告、APP等场景。',
        coverUrl: new URL('@/assets/homeimg/work2.jpg', import.meta.url).href,
        priceDisplay: '¥8,800起',
        tradeType: 'exclusive',
        tradeTypeText: '独家授权'
      },
      {
        id: '3',
        title: '商业摄影作品集',
        description: '高品质商业场景摄影作品集，涵盖办公、科技、生活等多种场景，适合企业宣传材料使用。',
        coverUrl: new URL('@/assets/homeimg/work3.jpg', import.meta.url).href,
        priceDisplay: '¥1,500起',
        tradeType: 'transfer',
        tradeTypeText: '完全转让'
      },
      {
        id: '4',
        title: '自然纪录短片',
        description: '4K高清自然风光纪录片素材，拍摄于全球各地自然保护区，总时长43分钟，提供剪辑版权。',
        coverUrl: new URL('@/assets/homeimg/work4.jpg', import.meta.url).href,
        priceDisplay: '¥5,600',
        tradeType: 'license',
        tradeTypeText: '授权使用'
      }
    ])

    const goToMarket = () => {
      router.push('/copyrightMarket/page/index')
    }
    
    const viewWorkDetails = (work) => {
      // 这里可以跳转到作品详情页面
      router.push(`/copyrightMarket/work/${work.id}`)
    }

    return {
      featuredWorks,
      goToMarket,
      viewWorkDetails
    }
  }
})
</script>

<style lang="scss" scoped>
.market-section {
  width: 100%;
  padding: 80px 0;
  background-color: #fff;
  position: relative;
  
  .market-container {
    width: $container-width;
    margin: 0 auto;
  }
  
  .section-title {
    font-size: 36px;
    color: #333;
    font-weight: 600;
    text-align: center;
    margin-bottom: 15px;
    position: relative;
    
    &::after {
      content: '';
      position: absolute;
      bottom: -15px;
      left: 50%;
      transform: translateX(-50%);
      width: 60px;
      height: 3px;
      background: linear-gradient(to right, $primary-color, lighten($primary-color, 15%));
    }
  }
  
  .section-subtitle {
    text-align: center;
    font-size: 18px;
    color: #666;
    margin: 30px auto;
    max-width: 600px;
  }
  
  .works-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    margin: 50px 0;
    
    @media screen and (max-width: 768px) {
      grid-template-columns: 1fr;
    }
  }
  
  .work-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    cursor: pointer;
    
    &:hover {
      transform: translateY(-8px);
      box-shadow: 0 15px 30px rgba(0, 0, 0, 0.12);
      
      .work-image img {
        transform: scale(1.05);
      }
      
      .work-title {
        color: $primary-color;
      }
    }
  }
  
  .work-image {
    height: 220px;
    overflow: hidden;
    position: relative;
    
    img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      transition: transform 0.5s ease;
    }
    
    .work-tags {
      position: absolute;
      top: 15px;
      right: 15px;
      display: flex;
      gap: 8px;
      
      span {
        padding: 5px 12px;
        border-radius: 20px;
        font-size: 12px;
        font-weight: 500;
        color: #fff;
        
        &.tag-license {
          background-color: #53b7d7;
        }
        
        &.tag-exclusive {
          background-color: #ff9800;
        }
        
        &.tag-transfer {
          background-color: #e91e63;
        }
      }
    }
  }
  
  .work-info {
    padding: 25px;
  }
  
  .work-title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
    transition: color 0.3s ease;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  
  .work-desc {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 20px;
    height: 66px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
  }
  
  .work-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  
  .work-price {
    display: flex;
    flex-direction: column;
    
    .price-label {
      font-size: 13px;
      color: #999;
    }
    
    .price-value {
      font-size: 20px;
      font-weight: 600;
      color: #ff5722;
    }
  }
  
  .work-btn {
    background-color: transparent;
    border: 1px solid $primary-color;
    color: $primary-color;
    transition: all 0.3s ease;
    
    &:hover {
      background-color: $primary-color;
      color: #fff;
    }
  }
  
  .view-more {
    text-align: center;
    margin-top: 40px;
  }
  
  .market-btn {
    padding: 14px 48px;
    background: $primary-color;
    border-color: $primary-color;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    z-index: 1;
    border-radius: 8px;
    letter-spacing: 1px;
    
    &::before {
      content: '';
      position: absolute;
      top: 0;
      left: -100%;
      width: 100%;
      height: 100%;
      background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
      transition: left 0.7s ease;
      z-index: -1;
    }

    &:hover {
      transform: translateY(-3px);
      box-shadow: 0 7px 15px rgba(83, 183, 215, 0.3);
      background: darken($primary-color, 5%);
      border-color: darken($primary-color, 5%);
      
      &::before {
        left: 100%;
      }
    }
    
    &:active {
      transform: translateY(0);
      box-shadow: 0 3px 8px rgba(83, 183, 215, 0.3);
    }
  }
  
  @media screen and (max-width: 1200px) {
    .market-container {
      width: 90%;
    }
  }
  
  @media screen and (max-width: 768px) {
    padding: 60px 0;
    
    .section-title {
      font-size: 28px;
    }
    
    .section-subtitle {
      font-size: 16px;
    }
    
    .works-grid {
      gap: 20px;
    }
    
    .work-image {
      height: 180px;
    }
    
    .work-info {
      padding: 20px;
    }
    
    .work-title {
      font-size: 18px;
    }
    
    .market-btn {
      padding: 12px 30px;
      font-size: 15px;
    }
  }
}
</style> 